package com.example.demo.design.demo20_iterator;

import com.sun.corba.se.pept.transport.ContactInfoListIterator;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 蔡超 on 2018/10/4.
 */
public class ConcreteAggregate implements Aggregate {
    private Object[] arr;
    private int index ;


    public ConcreteAggregate() {
        this.arr =new Object[100];
        index = arr.length - 1;
    }

    @Override
    public Iterator createIterator() {
        return new ConcreteIterator(this);
    }

    @Override
    public void add(Object obj) {
        arr[index] = obj;
    }

    @Override
    public Object get(int index) {
        return arr[index];
    }

    @Override
    public int getSize() {
        return arr.length;
    }


}
